<?php

class CAd extends Zend_Db_Table{
	
	protected $_name;
	
	protected $_primary;

	public function __construct(){
		
		$this->_name=R_PRE."ads";
		
		$this->_primary="adid";
		
		parent::__construct();
		
	}

	public function createAd($data){
		
		$adid=$this->insert($data);
		
		return $adid;
		
	}
	

	
	public function editAd($itemid,$data){
		
		$db=$this->getAdapter();
		
		$where = $db->quoteInto('itemid = ?', $itemid);
		
		$rows_affected=$db->update($this->_name,$data,$where);
		
		if($rows_affected!=1){
			
			return false;
			
		}else{
			
			return true;
			
		}
		
		
	}
	
	public function delAds($itemidArray){
		
		$db=$this->getAdapter();
		
		$itemidString=join(',',$itemidArray);
		
		$result=$db->query("DELETE FROM $this->_name WHERE itemid IN ($itemidString)");
		
		return $result;
		
	}
	

	
}